package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.AppScreenBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    //图片
    public static void savePicList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_pro_pic_list, json);
    }

    public static List<String> getPicList() {
        String json = sSpUtils.getString(Key.key_pro_pic_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    //视频
    public static void saveVideoList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_pro_video_list, json);
    }

    public static List<String> getVideoList() {
        String json = sSpUtils.getString(Key.key_pro_video_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    //音频
    public static void saveAudioList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_pro_audio_list, json);
    }

    public static List<String> getAudioList() {
        String json = sSpUtils.getString(Key.key_pro_audio_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    //应用方向
    public static void saveAppScreenList(List<AppScreenBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_app_orientation_list, json);
    }

    public static List<AppScreenBean> getAppScreenList() {
        String json = sSpUtils.getString(Key.key_app_orientation_list);
        return GsonUtils.fromJson(json, new TypeToken<List<AppScreenBean>>() {
        }.getType());
    }

    interface Key {

        //图片
        String key_pro_pic_list = "key_pro_pic_list";
        //视频
        String key_pro_video_list = "key_pro_video_list";
        //音频
        String key_pro_audio_list = "key_pro_audio_list";
        //应用方向
        String key_app_orientation_list = "key_app_orientation_list";

    }
}